import {reactive} from "vue";
import {getSKSJList} from "../../api/classes";
import {useStore} from "vuex";
interface CuPickerOpt {
    value: string
    label: string
}
export function useSKSJOpts(){

    const SKSJOpts = reactive<CuPickerOpt[]>([])
    const {state} = useStore()
    getSKSJList(state.user.userInfo.CUSER_ID).then(res => {
        if (res.ERROR[0].errcode == '0'){
            SKSJOpts.push(...res.DAT.map(item => ({
                value: item.CLASSTIME_ID + '',
                label: item.CLASSTIME_NAME
            })))
        }else {
            uni.showToast({
                title: res.ERROR[0].error,
                icon: 'none',
                mask: true
            })
        }
    }).catch(err => {
        uni.showToast({
            title: '获取列表失败',
            icon: 'error',
            mask: true
        })
    })

    return {
        SKSJOpts
    }
}
